package tool.ray;

import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
import org.w3c.dom.UserDataHandler;
import org.xml.sax.SAXException;

public class ActLogService {
	String strAction;
	String strTableName;
	String strBeforePrefix;
	String strAfterPrefix;
	String strReplacingTag;
	String strFields;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ActLogService s = new ActLogService();

	}
	public ActLogService(){

	}
	public void readSettingXML(String xmlPath) throws Exception{
		File file = new File(xmlPath);
		DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
		Document doc = db.parse(file);
		
		Node actionNode = doc.getElementsByTagName("action").item(0);
		Node tableNameNode = doc.getElementsByTagName("table_name").item(0);
		Node beforeImageNode = doc.getElementsByTagName("before_image").item(0);
		Node afterImageNode = doc.getElementsByTagName("after_image").item(0);
		Node replacingTagNode = doc.getElementsByTagName("replacing_tag").item(0);
		Node fieldsNode = doc.getElementsByTagName("fields").item(0);
		
		strAction = actionNode.getNodeValue();
		strTableName = tableNameNode.getNodeValue();
		strBeforePrefix = beforeImageNode.getNodeValue();
		strAfterPrefix = afterImageNode.getNodeValue();
		strReplacingTag = replacingTagNode.getNodeValue();
		strFields = fieldsNode.getNodeValue();
		
		
		
	}
	public String getAction(){
		return strAction;
	}

	public void setAction(String s){
		strAction = s;
	}
	
	public String getTableName(){
		return strTableName;
	}

	public void setTableName(String s){
		strTableName = s;
	}

	public String getBeforePrefix(){
		return strBeforePrefix;
	}

	public void setBeforePrefix(String s){
		strBeforePrefix = s;
	}
	
	public String getAfterPrefix(){
		return strBeforePrefix;
	}

	public void setAfterPrefix(String s){
		strAfterPrefix = s;
	}
	
	public String getReplacingTag(){
		return strBeforePrefix;
	}

	public void setReplacingTag(String s){
		strAfterPrefix = s;
	}
	
	
}
